*
* A minimal main program for a threaded GTK+ application
* looks like:
- * <informalexample>
- * <programlisting role="C">
+ * |[
* int
* main (int argc, char *argv[])
* {
*
* return 0;
* }
- * </programlisting>
- * </informalexample>
+ * ]|
*
* Callbacks require a bit of attention. Callbacks from GTK+ signals
* are made within the GTK+ lock. However callbacks from GLib (timeouts,
*
* Erik Mouw contributed the following code example to
* illustrate how to use threads within GTK+ programs.
- * <informalexample>
- * <programlisting role="C">
+ * |[
* /<!---->*-------------------------------------------------------------------------
* * Filename: gtk-thread.c
* * Version: 0.99.1
*
* return 0;
* }
- * </programlisting>
- * </informalexample>
+ * ]|
*
* Unfortunately, all of the above documentation holds with the X11
* backend only. With the Win32 or Quartz backends, GDK and GTK+ calls
* screen or workspace.
* <example>
* <title>Launching an application</title>
- * <informalexample>
- * <programlisting>
+ * |[
* GdkAppLaunchContext *context;
*
* context = gdk_display_get_app_launch_context (display);
* g_warning ("Launching failed: %s\n", error->message);
*
* g_object_unref (context);
- * </programlisting>
- * </informalexample>
+ * ]|
* </example>
*/
*
* <example>
* <title>Trapping an X error</title>
- * <programlisting>
+ * |[
* gdk_error_trap_push (<!-- -->);
*
* // ... Call the X function which may cause an error here ...
* {
* // ... Handle the error here ...
* }
- * </programlisting>
+ * ]|
* </example>
*/
void
*
* <example id="backend-specific">
* <title>Backend-specific code</title>
- * <programlisting>
+ * |[
* #ifdef GDK_WINDOWING_X11
* if (GDK_IS_X11_DISPLAY (display))
* {
* else
* #endif
* g_error ("Unsupported GDK backend");
- * </programlisting>
+ * ]|
* </example>
*/
* By default, GDK tries all included backends.
*
* For example,
- * <programlisting>
+ * |[
* gdk_set_allowed_backends ("wayland,quartz,*");
- * </programlisting>
+ * ]|
* instructs GDK to try the Wayland backend first,
* followed by the Quartz backend, and then all
* others.
* The event type is always the first field in all of the event types, and
* can always be accessed with the following code, no matter what type of
* event it is:
- * <informalexample>
- * <programlisting>
+ * |[
* GdkEvent *event;
* GdkEventType type;
*
* type = event->type;
- * </programlisting>
- * </informalexample>
+ * ]|
*
* To access other fields of the event, the pointer to the event
* can be cast to the appropriate event type, or the union member
* name can be used. For example if the event type is %GDK_BUTTON_PRESS
* then the x coordinate of the button press can be accessed with:
- * <informalexample>
- * <programlisting>
+ * |[
* GdkEvent *event;
* gdouble x;
*
* x = ((GdkEventButton*)event)->x;
- * </programlisting>
- * </informalexample>
+ * ]|
* or:
- * <informalexample>
- * <programlisting>
+ * |[
* GdkEvent *event;
* gdouble x;
*
* x = event->button.x;
- * </programlisting>
- * </informalexample>
+ * ]|
*/
union _GdkEvent
{
* <literal><Control>plus</literal> accelerator <Shift> should
* be masked out.
* </para>
- * <informalexample><programlisting>
+ * |[
* /* We want to ignore irrelevant modifiers like ScrollLock */
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
* gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
* if (keyval == GDK_PLUS &&
* (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
* /* Control was pressed */
- * </programlisting></informalexample>
+ * ]|
* <para>
* An older interpretation @consumed_modifiers was that it contained
* all modifiers that might affect the translation of the key;
* this allowed accelerators to be stored with irrelevant consumed
* modifiers, by doing:</para>
- * <informalexample><programlisting>
+ * |[
* /* XXX Don't do this XXX */
* if (keyval == accel_keyval &&
* (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
* /* Accelerator was pressed */
- * </programlisting></informalexample>
+ * ]|
* <para>
* However, this did not work if multi-modifier combinations were
* used in the keymap, since, for instance, <literal><Control></literal>
* <title>Draw transformed text with Pango and cairo</title>
* <!-- Note that this example is basically the same as
* demos/gtk-demo/rotated_text.c -->
- * <programlisting>
+ * |[
* #define RADIUS 100
* #define N_WORDS 10
* #define FONT "Sans Bold 18"
*
* g_object_unref (layout);
* g_object_unref (context);
- * </programlisting>
+ * ]|
* </example>
* <figure>
* <title>Output of <xref linkend="rotated-example"/></title>
* Here's an example of how the terminal example would be implemented, assuming
* a terminal area widget called "terminal" and a toplevel window "toplevel":
*
- * <informalexample><programlisting><![CDATA[
+ * |[
* GdkGeometry hints;
*
* hints.base_width = terminal->char_width;
* GDK_HINT_RESIZE_INC |
* GDK_HINT_MIN_SIZE |
* GDK_HINT_BASE_SIZE);
- * ]]></programlisting></informalexample>
+ * ]|
*
* The other useful fields are the @min_aspect and @max_aspect fields; these
* contain a width/height ratio as a floating point number. If a geometry widget
* This function should be called before a #GdkWindow is shown. This is
* best done by connecting to the #GtkWidget::realize signal:
*
- * <informalexample>
- * <programlisting>
+ * |[
* static void
* widget_realize_cb (GtkWidget *widget)
* {
* {
* g_signal_connect (window, "realize", G_CALLBACK (widget_realize_cb), NULL);
* }
- * </programlisting>
- * </informalexample>
+ * ]|
*
* Since: 3.10
*/
* </para>
* <example>
* <title>A #GtkDialog UI definition fragment.</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkActionGroup" id="actiongroup">
* <child>
* <object class="GtkAction" id="About">
* <accelerator key="F1" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
* </para>
* <example>
* <title>A class fragment implementing #GtkActivatable</title>
- * <programlisting><![CDATA[
+ * |[
*
* enum {
* ...
* foo_bar_set_label (button, gtk_action_get_label (action));
*
* ...
- * }]]></programlisting>
+ * }]|
* </example>
* </refsect2>
*/
* </variablelist>
* <example>
* <title>A #GtkIconFactory UI definition fragment.</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkIconFactory" id="iconfactory1">
* <sources>
* <source stock-id="apple-red" filename="apple-red.png"/>
* </object>
* </child>
* </object>
- * ]]>
- * </programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* and <literal>class</literal> declarations. As an example
* of such a statement:
*
- * <informalexample><programlisting>
+ * |[
* widget "mywindow.*.GtkEntry" style "my-entry-class"
- * </programlisting></informalexample>
+ * ]|
*
* attaches the style <literal>"my-entry-class"</literal> to all
* widgets whose <firstterm>widget path</firstterm> matches the
* Since GTK+ 2.10, <literal>widget_class</literal> paths can also contain
* <literal><classname></literal> substrings, which are matching
* the class with the given name and any derived classes. For instance,
- * <informalexample><programlisting>
+ * |[
* widget_class "*<GtkMenuItem>.GtkLabel" style "my-style"
- * </programlisting></informalexample>
+ * ]|
* will match #GtkLabel widgets which are contained in any kind of menu item.
*
* So, if you have a #GtkEntry named <literal>"myentry"</literal>, inside of a
* Matching against class is a little different. The pattern match is done
* against all class names in the widgets class hierarchy (not the layout
* hierarchy) in sequence, so the pattern:
- * <informalexample><programlisting>
+ * |[
* class "GtkButton" style "my-style"
- * </programlisting></informalexample>
+ * ]|
* will match not just #GtkButton widgets, but also #GtkToggleButton and
* #GtkCheckButton widgets, since those classes derive from #GtkButton.
*
* </para></listitem>
* <listitem><para>
* Merge multiple styles which use the same matching rule, for instance:
- * <informalexample><programlisting>
+ * |[
* style "Foo" { foo_content }
* class "X" style "Foo"
* style "Bar" { bar_content }
* class "X" style "Bar"
- * </programlisting></informalexample>
+ * ]|
* is faster to match as:
- * <informalexample><programlisting>
+ * |[
* style "FooBar" { foo_content bar_content }
* class "X" style "FooBar"
- * </programlisting></informalexample>
+ * ]|
* </para></listitem>
* <listitem><para>
* Use of wildcards should be avoided, this can reduce the individual RC style
*
* Here are some examples of color expressions:
*
- * <informalexample><programlisting>
+ * |[
* mix (0.5, "red", "blue")
* shade (1.5, mix (0.3, "#0abbc0", { 0.3, 0.5, 0.9 }))
* lighter (@<!-- -->foreground)
- * </programlisting></informalexample>
+ * ]|
*
* In a <literal>stock</literal> definition, icon sources are specified as a
* 4-tuple of image filename or icon name, text direction, widget state, and size, in that
* <literal>*</literal>. So for example, the following specifies different icons to
* use for left-to-right and right-to-left languages:
*
- * <informalexample><programlisting>
+ * |[
* stock["my-stock-item"] =
* {
* { "itemltr.png", LTR, *, * },
* { "itemrtl.png", RTL, *, * }
* }
- * </programlisting></informalexample>
+ * ]|
*
* This could be abbreviated as follows:
*
- * <informalexample><programlisting>
+ * |[
* stock["my-stock-item"] =
* {
* { "itemltr.png", LTR },
* { "itemrtl.png", RTL }
* }
- * </programlisting></informalexample>
+ * ]|
*
* You can specify custom icons for specific sizes, as follows:
*
- * <informalexample><programlisting>
+ * |[
* stock["my-stock-item"] =
* {
* { "itemmenusize.png", *, *, "gtk-menu" },
* { "itemtoolbarsize.png", *, *, "gtk-large-toolbar" }
* { "itemgeneric.png" } // implicit *, *, * as a fallback
* }
- * </programlisting></informalexample>
+ * ]|
*
* The sizes that come with GTK+ itself are <literal>"gtk-menu"</literal>,
* <literal>"gtk-small-toolbar"</literal>, <literal>"gtk-large-toolbar"</literal>,
*
* It's also possible to use custom icons for a given state, for example:
*
- * <informalexample><programlisting>
+ * |[
* stock["my-stock-item"] =
* {
* { "itemprelight.png", *, PRELIGHT },
* { "iteminsensitive.png", *, INSENSITIVE },
* { "itemgeneric.png" } // implicit *, *, * as a fallback
* }
- * </programlisting></informalexample>
+ * ]|
*
* When selecting an icon source to use, GTK+ will consider text direction most
* important, state second, and size third. It will select the best match based on
* taken on particular key presses. The form of a binding
* set declaration is:
*
- * <informalexample><programlisting>
+ * |[
* binding <replaceable>name</replaceable> {
* bind <replaceable>key</replaceable> {
* <replaceable>signalname</replaceable> (<replaceable>param</replaceable>, ...)
* }
* ...
* }
- * </programlisting></informalexample>
+ * ]|
*
* <replaceable>key</replaceable> is a string consisting of a
* series of modifiers followed by the name of a key. The
* This function attaches the widget's #GtkStyle to the widget's
* #GdkWindow. It is a replacement for
*
- * <programlisting>
+ * |[
* widget->style = gtk_style_attach (widget->style, widget->window);
- * </programlisting>
+ * ]|
*
* and should only ever be called in a derived widget's "realize"
* implementation which does not chain up to its parent class'
* and row numbers of the table. (Columns and rows are indexed from zero).
*
* To make a button occupy the lower right cell of a 2x2 table, use
- * <informalexample><programlisting>
+ * |[
* gtk_table_attach (table, button,
* 1, 2, // left, right attach
* 1, 2, // top, bottom attach
* xoptions, yoptions,
* xpadding, ypadding);
- * </programlisting></informalexample>
+ * ]|
* If you want to make the button span the entire bottom row, use @left_attach == 0 and @right_attach = 2 instead.
*
* Deprecated: 3.4: Use gtk_grid_attach() with #GtkGrid. Note that the attach
* Definitions</link>.
* </para></note>
*
- * <programlisting>
- * <![CDATA[
+ * |[
* <!ELEMENT ui (menubar|toolbar|popup|accelerator)* >
* <!ELEMENT menubar (menuitem|separator|placeholder|menu)* >
* <!ELEMENT menu (menuitem|separator|placeholder|menu)* >
* position (top|bot) #IMPLIED >
* <!ATTLIST accelerator name #IMPLIED
* action #REQUIRED >
- * ]]>
- * </programlisting>
+ * ]|
* There are some additional restrictions beyond those specified in the
* DTD, e.g. every toolitem must have a toolbar in its anchestry and
* every menuitem must have a menubar or popup in its anchestry. Since
*
* <example>
* <title>A UI definition</title>
- * <programlisting><![CDATA[
+ * |[
* <ui>
* <menubar>
* <menu name="FileMenu" action="FileMenuAction">
* </placeholder>
* </toolbar>
* </ui>
- * ]]></programlisting>
+ * ]|
* </example>
*
* The constructed widget hierarchy is very similar to the element tree
*
* <example>
* <title>An embedded GtkUIManager UI definition</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkUIManager" id="uiman">
* <child>
* <object class="GtkActionGroup" id="actiongroup">
* <object class="GtkMenuBar" id="menubar1" constructor="uiman"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* application, but in order to ensure proper translation of the title,
* applications should set the title property explicitly when constructing
* a GtkAboutDialog, as shown in the following example:
- * <informalexample><programlisting>
+ * |[
* gtk_show_about_dialog (NULL,
* "program-name", "ExampleCode",
* "logo", example_logo,
* "title" _("About ExampleCode"),
* NULL);
- * </programlisting></informalexample>
+ * ]|
*
* It is also possible to show a #GtkAboutDialog like any other #GtkDialog,
* e.g. using gtk_dialog_run(). In this case, you might need to know that
* though it is almost always used to display just one accelerator key.
* <example>
* <title>Creating a simple menu item with an accelerator key.</title>
- * <programlisting>
+ * |[
* GtkWidget *save_item;
* GtkAccelGroup *accel_group;
*
* accelerators. We just need to make sure we use GTK_ACCEL_VISIBLE here. *<!---->/
* gtk_widget_add_accelerator (save_item, "activate", accel_group,
* GDK_KEY_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- * </programlisting>
+ * ]|
* </example>
*/
* </figure>
*
* <example id="gtkapplication"><title>A simple application</title>
- * <programlisting>
+ * |[
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/bloatpad.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
- * </programlisting>
+ * ]|
* </example>
*
* GtkApplication optionally registers with a session manager
* using gtk_header_bar_set_show_close_button().
*
* <example><title>A GtkApplicationWindow with a menubar</title>
- * <programlisting><![CDATA[
+ * |[
* app = gtk_application_new ();
*
* builder = gtk_builder_new ();
* ...
*
* window = gtk_application_window_new (app);
- * ]]>
- * </programlisting>
+ * ]|
* </example>
*
* <example><title>Handling fallback yourself</title>
- * <programlisting>
+ * |[
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/sunny.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
- * </programlisting>
+ * ]|
* </example>
*
* The XML format understood by #GtkBuilder for #GMenuModel consists
* For example for binding Control and the left or right cursor keys
* of a #GtkEntry widget to the #GtkEntry::move-cursor signal (so movement
* occurs in 3-character steps), the following binding can be used:
- * <informalexample><programlisting>
+ * |[
* @binding-set MoveCursor3
* {
* bind "<Control>Right" { "move-cursor" (visual-positions, 3, 0) };
* {
* gtk-key-bindings: MoveCursor3;
* }
- * </programlisting></informalexample>
+ * ]|
* </para>
* </refsect2>
* <refsect2 id="gtk-bindings-unbind">
* <link linkend="gtk-bindings-install">Installing a key binding</link>
* works as expected. The same mechanism can not be used to "unbind"
* existing bindings, however.
- * <informalexample><programlisting>
+ * |[
* @binding-set MoveCursor3
* {
* bind "<Control>Right" { };
* {
* gtk-key-bindings: MoveCursor3;
* }
- * </programlisting></informalexample>
+ * ]|
* The above example will not have the desired effect of causing
* "<Control>Right" and "<Control>Left" key presses to
* be ignored by GTK+. Instead, it just causes any existing bindings
* eventually lookup and find the default GTK+ bindings for entries which
* implement word movement. To keep GTK+ from activating its default
* bindings, the "unbind" keyword can be used like this:
- * <informalexample><programlisting>
+ * |[
* @binding-set MoveCursor3
* {
* unbind "<Control>Right";
* {
* gtk-key-bindings: MoveCursor3;
* }
- * </programlisting></informalexample>
+ * ]|
* Now, GTK+ will find a match when looking up "<Control>Right"
* and "<Control>Left" key presses before it resorts to its default
* bindings, and the match instructs it to abort ("unbind") the search,
*
* Signal descriptions may either bind a key combination to
* one or more signals:
- * <informalexample><programlisting>
+ * |[
* bind "key" {
* "signalname" (param, ...)
* ...
* }
- * </programlisting></informalexample>
+ * ]|
*
* Or they may also unbind a key combination:
- * <informalexample><programlisting>
+ * |[
* unbind "key"
- * </programlisting></informalexample>
+ * ]|
*
* Key combinations must be in a format that can be parsed by
* gtk_accelerator_parse().
* <link linkend="XML-UI">GtkUIManager UI Definitions</link>, which are more
* limited in scope. It is common to use <filename>.ui</filename> as the filename extension for files containing GtkBuilder UI definitions.
* </para>
- * <programlisting>
+ * |[
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gtk/gtkbuilder.rnc">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
- * </programlisting>
+ * ]|
* <para>
* The toplevel element is <interface>. It optionally takes a "domain"
* attribute, which will make the builder look for translated strings using
* </para>
* <example>
* <title>A GtkBuilder UI Definition</title>
- * <programlisting><![CDATA[
+ * |[
* <interface>
* <object class="GtkDialog" id="dialog1">
* <child internal-child="vbox">
* </child>
* </object>
* </interface>
- * ]]></programlisting>
+ * ]|
* </example>
* <para>
* Beyond this general structure, several object classes define their own XML
* of a #GtkTreeModel one would do the following:
* <example>
* <title>Requesting the width of a handful of GtkTreeModel rows</title>
- * <programlisting>
+ * |[
* GtkTreeIter iter;
* gint minimum_width;
* gint natural_width;
* valid = gtk_tree_model_iter_next (model, &iter);
* }
* gtk_cell_area_context_get_preferred_width (context, &minimum_width, &natural_width);
- * </programlisting>
+ * ]|
* </example>
* Note that in this example it's not important to observe the
* returned minimum and natural width of the area for each row
* take up the full width of the layouting widget would look like:
* <example>
* <title>A typical get_preferred_width(<!-- -->) implementation</title>
- * <programlisting>
+ * |[
* static void
* foo_get_preferred_width (GtkWidget *widget,
* gint *minimum_size,
*
* gtk_cell_area_context_get_preferred_width (priv->context, minimum_size, natural_size);
* }
- * </programlisting>
+ * ]|
* </example>
* In the above example the Foo widget has to make sure that some
* row sizes have been calculated (the amount of rows that Foo judged
* root level of a #GtkTreeModel one would do the following:
* <example>
* <title>Requesting the height for width of a handful of GtkTreeModel rows</title>
- * <programlisting>
+ * |[
* GtkTreeIter iter;
* gint minimum_height;
* gint natural_height;
*
* valid = gtk_tree_model_iter_next (model, &iter);
* }
- * </programlisting>
+ * ]|
* </example>
* Note that in the above example we would need to cache the heights
* returned for each row so that we would know what sizes to render the
* runs as follows:
* <example>
* <title>Requesting the width of a handful of GtkTreeModel rows</title>
- * <programlisting>
+ * |[
* GtkAllocation allocation;
* GdkRectangle cell_area = { 0, };
* GtkTreeIter iter;
*
* valid = gtk_tree_model_iter_next (model, &iter);
* }
- * </programlisting>
+ * ]|
* </example>
* Note that the cached height in this example really depends on how
* the layouting widget works. The layouting widget might decide to
* should be implemented:
* <example>
* <title>Implementing keyboard focus navigation</title>
- * <programlisting>
+ * |[
* static gboolean
* foo_focus (GtkWidget *widget,
* GtkDirectionType direction)
* }
* return have_focus;
* }
- * </programlisting>
+ * ]|
* </example>
* Note that the layouting widget is responsible for matching the
* GtkDirectionType values to the way it lays out its cells.
*
* <example>
* <title>A UI definition fragment specifying attributes</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkCellView">
* <child>
* <object class="GtkCellRendererText"/>
* </attributes>
* </child>"
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
*
* Furthermore for implementations of GtkCellLayout that use a #GtkCellArea
* can contain multiple <property> elements defined in the normal way.
* <example>
* <title>A UI definition fragment specifying cell properties</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkTreeViewColumn">
* <child>
* <object class="GtkCellRendererText"/>
* </cell-packing>
* </child>"
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* to the fact that these widgets internally use a #GtkCellArea.
* The cell area is exposed as a construct-only property by these
* widgets. This means that it is possible to e.g. do
- * <informalexample><programlisting>
+ * |[
* combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL);
- * </programlisting></informalexample>
+ * ]|
* to use a custom cell area with a combo box. But construct properties
* are only initialized after instance init()
* functions have run, which means that using functions which rely on
* cause the default cell area to be instantiated. In this case, a provided
* construct property value will be ignored (with a warning, to alert
* you to the problem).
- * <informalexample><programlisting>
+ * |[
* static void
* my_combo_box_init (MyComboBox *b)
* {
* */
* return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL);
* }
- * </programlisting></informalexample>
+ * ]|
* If supporting alternative cell areas with your derived widget is
* not important, then this does not have to concern you. If you want
* to support alternative cell areas, you can do so by moving the
*
* <example>
* <title>A UI definition fragment specifying GtkComboBoxText items</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkComboBoxText">
* <items>
* <item translatable="yes" id="factory">Factory</item>
* <item translatable="yes" id="subway">Subway</item>
* </items>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* the container must return the height for its minimum width. This is easily achieved by
* simply calling the reverse apis implemented for itself as follows:
*
- * <programlisting><![CDATA[
+ * |[
* static void
* foo_container_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
* {
* stacked vertically (or whatever is appropriate for this container) ...
* }
* }
- * ]]></programlisting>
+ * ]|
*
* Similarly, when gtk_widget_get_preferred_width_for_height() is called for a container or widget
* that is height-for-width, it then only needs to return the base minimum width like so:
*
- * <programlisting><![CDATA[
+ * |[
* static void
* foo_container_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
* gint *min_width, gint *nat_width)
* of the children collectively if the container were to be allocated the said height ...
* }
* }
- * ]]></programlisting>
+ * ]|
*
* Height for width requests are generally implemented in terms of a virtual allocation
* of widgets in the input orientation. Assuming an height-for-width request mode, a container
* child properties for the child.
* <example>
* <title>Child properties in UI definitions</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkVBox">
* <child>
* <object class="GtkLabel"/>
* </packing>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* Since 2.16, child properties can also be marked as translatable using
* the same "translatable", "comments" and "context" attributes that are used
* the CSS file, make sure the engine is loaded first by specifying
* the engine property, either in a previous rule or within the same
* one.
- * <programlisting>
+ * |[
* * {
* engine: someengine;
* -SomeEngine-custom-property: 2;
* }
- * </programlisting>
+ * ]|
* </note>
*
* Since: 3.0
* front of the block, separated by commas.
* </para>
* <example><title>A rule set with two selectors</title>
- * <programlisting language="text">
+ * |[
* GtkButton, GtkEntry {
* color: #ff00ea;
* font: Comic Sans 12
* }
- * </programlisting>
+ * ]|
* </example>
* </refsect2>
* <refsect2 id="gtkcssprovider-selectors">
* </para>
* <example>
* <title>Widget classes and names in selectors</title>
- * <programlisting language="text">
+ * |[
* /* Theme labels that are descendants of a window */
* GtkWindow GtkLabel {
* background-color: #898989
* #main-entry {
* background-color: #f0a810
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* Widgets may also define style classes, which can be used for matching.
* </para>
* <example>
* <title>Style classes in selectors</title>
- * <programlisting language="text">
+ * |[
* /* Theme all widgets defining the class entry */
* .entry {
* color: #39f1f9;
* GtkSpinButton.entry {
* color: #900185
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* In complicated widgets like e.g. a GtkNotebook, it may be desirable
* </para>
* <example>
* <title>Regions in selectors</title>
- * <programlisting language="text">
+ * |[
* /* Theme any label within a notebook */
* GtkNotebook GtkLabel {
* color: #f90192;
* GtkNotebook tab:first-child GtkLabel {
* color: #89d012;
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* Another use of pseudo-classes is to match widgets depending on their
* </para>
* <example>
* <title>Styling specific widget states</title>
- * <programlisting language="text">
+ * |[
* /* Theme active (pressed) buttons */
* GtkButton:active {
* background-color: #0274d9;
* GtkCheckButton:inconsistent {
* background-color: #20395a;
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* Widget state pseudoclasses may only apply to the last element
* </para>
* <example>
* <title>Using the @import rule</title>
- * <programlisting language="text">
+ * |[
* @import url ("path/to/common.css");
- * </programlisting>
+ * ]|
* </example>
* <para id="css-binding-set">
* In order to extend key bindings affecting different widgets, GTK+
* </para>
* <example>
* <title>Using the @binding rule</title>
- * <programlisting language="text">
+ * |[
* @binding-set binding-set1 {
* bind "<alt>Left" { "move-cursor" (visual-positions, -3, 0) };
* unbind "End";
* GtkEntry {
* gtk-key-bindings: binding-set1, binding-set2;
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* GTK+ also supports an additional @define-color rule, in order
* </para>
* <example>
* <title>Defining colors</title>
- * <programlisting language="text">
+ * |[
* @define-color bg_color #f9a039;
*
* * {
* background-color: @bg_color;
* }
- * </programlisting>
+ * ]|
* </example>
* </refsect2>
* <refsect2 id="gtkcssprovider-symbolic-colors">
* </para>
* <example>
* <title>Using symbolic colors</title>
- * <programlisting language="text">
+ * |[
* @define-color entry-color shade (@bg_color, 0.7);
*
* GtkEntry {
* shade (#fff, 0.5),
* 0.8);
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* The various ways to express colors in GTK+ CSS are:
* </para>
* <example>
* <title>Using engine-specific style properties</title>
- * <programlisting>
+ * |[
* * {
* engine: clearlooks;
* border-radius: 4;
* -GtkPaned-handle-size: 6;
* -clearlooks-colorize-scrollbar: false;
* }
- * </programlisting>
+ * ]|
* </example>
* </refsect2>
*/
* in the dialog.
* <example>
* <title>Simple GtkDialog usage</title>
- * <programlisting>
+ * |[
* /* Function to open a dialog box displaying the message provided. */
* void
* quick_message (gchar *message)
* gtk_container_add (GTK_CONTAINER (content_area), label);
* gtk_widget_show_all (dialog);
* }
- * </programlisting>
+ * ]|
* </example>
*
* <refsect2 id="GtkDialog-BUILDER-UI"><title>GtkDialog as GtkBuildable</title>
* </para>
* <example>
* <title>A #GtkDialog UI definition fragment.</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkDialog" id="dialog1">
* <child internal-child="vbox">
* <object class="GtkVBox" id="vbox">
* <action-widget response="cancel">button_cancel</action-widget>
* </action-widgets>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
*
* <example>
* <title>Simple GtkDrawingArea usage</title>
- * <programlisting>
+ * |[
* gboolean
* draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
* {
* gtk_widget_set_size_request (drawing_area, 100, 100);
* g_signal_connect (G_OBJECT (drawing_area), "draw",
* G_CALLBACK (draw_callback), NULL);
- * </programlisting>
+ * ]|
* </example>
*
* Draw signals are normally delivered when a drawing area first comes
*
* <example>
* <title>Forcing entry to uppercase.</title>
- * <programlisting>
+ * |[
* #include <ctype.h>
*
* void
*
* g_free (result);
* }
- * </programlisting>
+ * ]|
* </example>
*/
*
* This is equivalent to:
*
- * <informalexample><programlisting>
+ * |[
* gtk_entry_buffer_get_text (gtk_entry_get_buffer (entry));
- * </programlisting></informalexample>
+ * ]|
*
* Return value: a pointer to the contents of the widget as a
* string. This string points to internally allocated
*
* This is equivalent to:
*
- * <informalexample><programlisting>
+ * |[
* gtk_entry_buffer_set_max_length (gtk_entry_get_buffer (entry), max);
- * </programlisting></informalexample>
+ * ]|
**/
void
gtk_entry_set_max_length (GtkEntry *entry,
*
* This is equivalent to:
*
- * <informalexample><programlisting>
+ * |[
* gtk_entry_buffer_get_max_length (gtk_entry_get_buffer (entry));
- * </programlisting></informalexample>
+ * ]|
*
* Return value: the maximum allowed number of characters
* in #GtkEntry, or 0 if there is no maximum.
*
* This is equivalent to:
*
- * <informalexample><programlisting>
+ * |[
* gtk_entry_buffer_get_length (gtk_entry_get_buffer (entry));
- * </programlisting></informalexample>
+ * ]|
*
* Return value: the current number of characters
* in #GtkEntry, or 0 if there are none.
* its expansion state. You should watch this property with a signal
* connection as follows:
* </para>
- * <informalexample>
- * <programlisting id="expander-callback-example">
+ * |[
* expander = gtk_expander_new_with_mnemonic ("_More Options");
* g_signal_connect (expander, "notify::expanded",
* G_CALLBACK (expander_callback), NULL);
* /* Hide or destroy widgets */
* }
* }
- * </programlisting>
- * </informalexample>
+ * ]|
* </refsect2>
* <refsect2 id="GtkExpander-BUILDER-UI">
* <title>GtkExpander as GtkBuildable</title>
* </para>
* <example>
* <title>A UI definition fragment with GtkExpander</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkExpander">
* <child type="label">
* <object class="GtkLabel" id="expander-label"/>
* <object class="GtkEntry" id="expander-content"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*
* </para>
* <example id="example-gtkfilechooser-preview">
* <title>Sample Usage</title>
- * <programlisting>
+ * |[
* {
* GtkImage *preview;
*
*
* gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
* }
- * </programlisting>
+ * ]|
* </example>
* </refsect2>
* <refsect2 id="gtkfilechooser-extra">
* </para>
* <example id="example-gtkfilechooser-extra">
* <title>Sample Usage</title>
- * <programlisting>
+ * |[
*
* GtkWidget *toggle;
*
* gtk_widget_show (toggle);
* gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
* }
- * </programlisting>
+ * ]|
* </example>
* <note>
* If you want to set more than one extra widget in the file
* illustrates this.
* <example id="gtkfilechooser-confirmation">
* <title>Custom confirmation</title>
- * <programlisting>
+ * |[
* static GtkFileChooserConfirmation
* confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
* {
* save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
*
* gtk_widget_destroy (chooser);
- * </programlisting>
+ * ]|
* </example>
*
* Returns: a #GtkFileChooserConfirmation value that indicates which
*
* <example>
* <title>Create a button to let the user select a file in /etc</title>
- * <programlisting>
+ * |[
* {
* GtkWidget *button;
*
* gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button),
* "/etc");
* }
- * </programlisting>
+ * ]|
* </example>
*
* The #GtkFileChooserButton supports the #GtkFileChooserAction<!-- -->s
* In the simplest of cases, you can the following code to use
* #GtkFileChooserDialog to select a file for opening:
* <para>
- * <informalexample><programlisting>
+ * |[
* GtkWidget *dialog;
*
* dialog = gtk_file_chooser_dialog_new ("Open File",
* }
*
* gtk_widget_destroy (dialog);
- * </programlisting></informalexample>
+ * ]|
* </para>
* To use a dialog for saving, you can use this:
* <para>
- * <informalexample><programlisting>
+ * |[
* GtkWidget *dialog;
*
* dialog = gtk_file_chooser_dialog_new ("Save File",
* }
*
* gtk_widget_destroy (dialog);
- * </programlisting></informalexample>
+ * ]|
* </para>
* </example>
* <section id="gtkfilechooserdialog-setting-up">
* #GTK_RESPONSE_ACCEPT and #GTK_RESPONSE_CANCEL. For example, you
* could call gtk_file_chooser_dialog_new() as follows:
* <para>
- * <informalexample><programlisting>
+ * |[
* GtkWidget *dialog;
*
* dialog = gtk_file_chooser_dialog_new ("Open File",
* _("_Cancel"), GTK_RESPONSE_CANCEL,
* _("_Open"), GTK_RESPONSE_ACCEPT,
* NULL);
- * </programlisting></informalexample>
+ * ]|
* </para>
* This will create buttons for "Cancel" and "Open" that use stock
* response identifiers from #GtkResponseType. For most dialog
*
* <example>
* <title>A UI definition fragment specifying GtkFileFilter rules</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkFileFilter">
* <mime-types>
* <mime-type>text/plain</mime-type>
* <pattern>*.png</pattern>
* </patterns>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* </para>
* <example>
* <title>A UI definition fragment with GtkFrame</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkFrame">
* <child type="label">
* <object class="GtkLabel" id="frame-label"/>
* <object class="GtkEntry" id="frame-content"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
* so that the icon information is shared with other people
* looking up icons. In the case where the default screen is
* being used, looking up an icon can be as simple as:
- * <informalexample>
- * <programlisting>
+ * |[
* GError *error = NULL;
* GtkIconTheme *icon_theme;
* GdkPixbuf *pixbuf;
* // Use the pixbuf
* g_object_unref (pixbuf);
* }
- * </programlisting>
- * </informalexample>
+ * ]|
*/
* #GdkPixbuf ("pixel buffer") from a file, and then display that.
* There's a convenience function to do this, gtk_image_new_from_file(),
* used as follows:
- * <informalexample><programlisting>
+ * |[
* GtkWidget *image;
* image = gtk_image_new_from_file ("myfile.png");
- * </programlisting></informalexample>
+ * ]|
* If the file isn't loaded successfully, the image will contain a
* "broken image" icon similar to that used in many web browsers.
* If you want to handle errors in loading the file yourself,
* #GtkEventBox, then connect to the event signals on the event box.
* <example>
* <title>Handling button press events on a #GtkImage.</title>
- * <programlisting>
+ * |[
* static gboolean
* button_press_callback (GtkWidget *event_box,
* GdkEventButton *event,
*
* return image;
* }
- * </programlisting>
+ * ]|
* </example>
*
* When handling events on the event box, keep in mind that coordinates
* implements a subclass of #GtkIMContext or #GtkIMContextSimple and exports
* these four functions:
*
- * <informalexample><programlisting>
+ * |[
* void im_module_init(#GTypeModule *module);
- * </programlisting></informalexample>
+ * ]|
* This function should register the #GType of the #GtkIMContext subclass which
* implements the input method by means of g_type_module_register_type(). Note
* that g_type_register_static() cannot be used as the type needs to be
* registered dynamically.
*
- * <informalexample><programlisting>
+ * |[
* void im_module_exit(void);
- * </programlisting></informalexample>
+ * ]|
* Here goes any cleanup code your input method might require on module unload.
*
- * <informalexample><programlisting>
+ * |[
* void im_module_list(const #GtkIMContextInfo ***contexts, int *n_contexts)
* {
* *contexts = info_list;
* *n_contexts = G_N_ELEMENTS (info_list);
* }
- * </programlisting></informalexample>
+ * ]|
* This function returns the list of input methods provided by the module. The
* example implementation above shows a common solution and simply returns a
* pointer to statically defined array of #GtkIMContextInfo items for each
* provided input method.
*
- * <informalexample><programlisting>
+ * |[
* #GtkIMContext * im_module_create(const #gchar *context_id);
- * </programlisting></informalexample>
+ * ]|
* This function should return a pointer to a newly created instance of the
* #GtkIMContext subclass identified by @context_id. The context ID is the same
* as specified in the #GtkIMContextInfo array returned by im_module_list().
*
* <example>
* <title>Simple GtkInfoBar usage.</title>
- * <programlisting>
+ * |[
* /* set up info bar */
* info_bar = gtk_info_bar_new ();
* gtk_widget_set_no_show_all (info_bar, TRUE);
* gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
* GTK_MESSAGE_ERROR);
* gtk_widget_show (info_bar);
- * </programlisting>
+ * ]|
* </example>
*
* <refsect2 id="GtkInfoBar-BUILDER-UI">
*
* <example>
* <title>A UI definition fragment specifying Pango attributes</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkLabel">
* <attributes>
* <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
* <attribute name="background" value="red" start="5" end="10"/>"
* </attributes>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* The start and end attributes specify the range of characters to which the
* Pango attribute applies. If start and end are not specified, the attribute is
* using gtk_label_set_mnemonic_widget(). Here's a simple example where
* the label is inside a button:
*
- * <informalexample>
- * <programlisting>
+ * |[
* // Pressing Alt+H will activate this button
* button = gtk_button_new (<!-- -->);
* label = gtk_label_new_with_mnemonic ("_Hello");
* gtk_container_add (GTK_CONTAINER (button), label);
- * </programlisting>
- * </informalexample>
+ * ]|
*
* There's a convenience function to create buttons with a mnemonic label
* already inside:
*
- * <informalexample>
- * <programlisting>
+ * |[
* // Pressing Alt+H will activate this button
* button = gtk_button_new_with_mnemonic ("_Hello");
- * </programlisting>
- * </informalexample>
+ * ]|
*
* To create a mnemonic for a widget alongside the label, such as a
* #GtkEntry, you have to point the label at the entry with
* gtk_label_set_mnemonic_widget():
*
- * <informalexample>
- * <programlisting>
+ * |[
* // Pressing Alt+H will focus the entry
* entry = gtk_entry_new (<!-- -->);
* label = gtk_label_new_with_mnemonic ("_Hello");
* gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
- * </programlisting>
- * </informalexample>
+ * ]|
* </para>
* </refsect2>
* <refsect2>
* linkend="PangoMarkupFormat">markup format</link>.
* Here's how to create a label with a small font:
*
- * <informalexample>
- * <programlisting>
+ * |[
* label = gtk_label_new (NULL);
* gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
- * </programlisting>
- * </informalexample>
+ * ]|
*
* (See <link
* linkend="PangoMarkupFormat">complete documentation</link> of available
* way they appear in web browsers, with colored, underlined text. The title
* attribute is displayed as a tooltip on the link. An example looks like this:
*
- * <informalexample><programlisting>
+ * |[
* gtk_label_set_markup (label, "Go to the <a href="http://www.gtk.org" title="<i>Our</i> website">GTK+ website</a> for more...");
- * </programlisting></informalexample>
+ * ]|
*
* It is possible to implement custom handling for links and their tooltips with
* the #GtkLabel::activate-link signal and the gtk_label_get_current_uri() function.
*
* <example>
* <title>Adding a custom offset on the bar</title>
- * <programlisting>
+ * |[
*
* static GtkWidget *
* create_level_bar (void)
*
* return level_bar;
* }
- * </programlisting>
+ * ]|
* </example>
*
* The default interval of values is between zero and one, but it's possible to
*
* <example>
* <title>Creating a simple list store.</title>
- * <programlisting>
+ * |[
* enum {
* COLUMN_STRING,
* COLUMN_INT,
* COLUMN_BOOLEAN, TRUE,
* -1);
* }
- * </programlisting>
+ * ]|
* </example>
*
* <refsect2>
*
* <example>
* <title>A UI Definition fragment for a list store</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkListStore">
* <columns>
* <column type="gchararray"/>
* </row>
* </data>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* </para>
* <example>
* <title>Typical main() function for a GTK+ application</title>
- * <programlisting>
+ * |[
* int
* main (int argc, char **argv)
* {
* /* The user lost interest */
* return 0;
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* It's OK to use the GLib main loop directly instead of gtk_main(), though it
*
* <example>
* <title>Updating the UI during a long computation</title>
- * <programlisting>
+ * |[
* /* computation going on... */
*
* while (gtk_events_pending ())
* gtk_main_iteration ();
*
* /* ...computation continued */
- * </programlisting>
+ * ]|
* </example>
*
* Returns: %TRUE if any events are pending, %FALSE otherwise
*
* <example>
* <title>A persistent window</title>
- * <programlisting>
+ * |[
* #include <gtk/gtk.h><
*
* int
*
* return 0;
* }
- * </programlisting>
+ * ]|
* </example>
*
* Returns: %TRUE
*
* <example>
* <title>Connecting the popup signal handler.</title>
- * <programlisting>
+ * |[
* /<!---->* connect our handler which will popup the menu *<!---->/
* g_signal_connect_swapped (window, "button_press_event",
* G_CALLBACK (my_popup_handler), menu);
- * </programlisting>
+ * ]|
* </example>
*
* <example>
* <title>Signal handler which displays a popup menu.</title>
- * <programlisting>
+ * |[
* static gint
* my_popup_handler (GtkWidget *widget, GdkEvent *event)
* {
*
* return FALSE;
* }
- * </programlisting>
+ * ]|
* </example>
*/
*
* <example>
* <title>Setting markup and accelerator on a MenuItem</title>
- * <programlisting><![CDATA[
+ * |[
* GtkWidget *child = gtk_bin_get_child (GTK_BIN (menu_item));
* gtk_label_set_markup (GTK_LABEL (child), "<i>new label</i> with <b>markup</b>");
* gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), GDK_KEY_1, 0);
- * ]]></programlisting>
+ * ]|
* </example>
*
* <refsect2 id="GtkMenuItem-BUILDER-UI">
* attribute of a <child> element.
* <example>
* <title>A UI definition fragment with submenus</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkMenuItem">
* <child type="submenu">
* <object class="GtkMenu"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
*
* <example>
* <title>A UI definition fragment with menus</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkMenuToolButton">
* <child type="menu">
* <object class="GtkMenu"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* returns when any dialog button is clicked.
* <example>
* <title>A modal dialog.</title>
- * <programlisting>
+ * |[
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* filename, g_strerror (errno));
* gtk_dialog_run (GTK_DIALOG (dialog));
* gtk_widget_destroy (dialog);
- * </programlisting>
+ * ]|
* </example>
* You might do a non-modal #GtkMessageDialog as follows:
* <example>
* <title>A non-modal dialog.</title>
- * <programlisting>
+ * |[
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* g_signal_connect_swapped (dialog, "response",
* G_CALLBACK (gtk_widget_destroy),
* dialog);
- * </programlisting>
+ * ]|
* </example>
*
* <refsect2 id="GtkMessageDialog-BUILDER-UI">
* may contain special XML characters, you should use g_markup_printf_escaped()
* to escape it.
- * <informalexample><programlisting>
+ * |[
* gchar *msg;
*
* msg = g_markup_printf_escaped (message_format, ...);
* gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg);
* g_free (msg);
- * </programlisting></informalexample>
+ * ]|
*
* Since: 2.6
*/
* </para>
* <example>
* <title>A UI definition fragment with GtkNotebook</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkNotebook">
* <child>
* <object class="GtkLabel" id="notebook-content">
* </object>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
*
* <example>
* <title>A page setup dialog</title>
- * <programlisting>
+ * |[
* static GtkPrintSettings *settings = NULL;
* static GtkPageSetup *page_setup = NULL;
*
*
* page_setup = new_page_setup;
* }
- * </programlisting>
+ * ]|
* </example>
*
* Printing support was added in GTK+ 2.10.
*
* <example>
* <title>Creating a paned widget with minimum sizes.</title>
- * <programlisting>
+ * |[
* GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
* GtkWidget *frame1 = gtk_frame_new (NULL);
* GtkWidget *frame2 = gtk_frame_new (NULL);
*
* gtk_paned_pack2 (GTK_PANED (hpaned), frame2, FALSE, FALSE);
* gtk_widget_set_size_request (frame2, 50, -1);
- * </programlisting>
+ * ]|
* </example>
*/
*
* <example>
* <title>Using GtkPrintContext in a #GtkPrintOperation::draw-page callback</title>
- * <programlisting>
+ * |[
* static void
* draw_page (GtkPrintOperation *operation,
* GtkPrintContext *context,
*
* g_object_unref (layout);
* }
- * </programlisting>
+ * ]|
* </example>
*
* Printing support was added in GTK+ 2.10.
*
* <example>
* <title>The high-level printing API</title>
- * <programlisting>
+ * |[
* static GtkPrintSettings *settings = NULL;
*
* static void
*
* g_object_unref (print);
* }
- * </programlisting>
+ * ]|
* </example>
*
* By default GtkPrintOperation uses an external application to do
*
* <example>
* <title>A #GtkPrintUnixDialog UI definition fragment.</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkPrintUnixDialog" id="dialog1">
* <child internal-child="notebook">
* <object class="GtkNotebook" id="notebook">
* </object>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
*
* <example>
* <title>How to create a group of two radio buttons.</title>
- * <programlisting>
+ * |[
* void create_radio_buttons (void) {
*
* GtkWidget *window, *radio1, *radio2, *box, *entry;
* gtk_widget_show_all (window);
* return;
* }
- * </programlisting>
+ * ]|
* </example>
*
* When an unselected button in the group is clicked the clicked button
*
* <example>
* <title>How to create a group of radio menu items.</title>
- * <programlisting>
+ * |[
* GSList *group = NULL;
* GtkWidget *item;
* gint i;
* if (i == 1)
* gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
* }
- * </programlisting>
+ * ]|
* </example>
*/
* <title>Typical usage</title>
* In the simplest of cases, you can use the following code to use
* a #GtkRecentChooserDialog to select a recently used file:
- * <programlisting>
+ * |[
* GtkWidget *dialog;
*
* dialog = gtk_recent_chooser_dialog_new ("Recent Documents",
* }
*
* gtk_widget_destroy (dialog);
- * </programlisting>
+ * ]|
* </example>
*
* Recently used files are supported since GTK+ 2.10.
*
* <example>
* <title>A UI definition fragment specifying GtkRecentFilter rules</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkRecentFilter">
* <mime-types>
* <mime-type>text/plain</mime-type>
* <application>glade</application>
* </applications>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
*
* <example>
* <title>Creating a search bar</title>
- * <programlisting>
+ * |[
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/search-bar.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
- * </programlisting>
+ * ]|
* </example>
*
* Since: 3.10
*
* <example>
* <title>Showing the search bar on key presses</title>
- * <programlisting><![CDATA[
+ * |[
* static gboolean
* window_key_press_event_cb (GtkWidget *widget,
* GdkEvent *event,
*
* g_signal_connect (window, "key-press-event",
* G_CALLBACK (window_key_press_event_cb), search_bar);
- * ]]></programlisting>
+ * ]|
* </example>
*
* Return value: %GDK_EVENT_STOP if the key press event resulted
* need to be aware that settings that are specific to individual widgets
* may not be available before the widget type has been realized at least
* once. The following example demonstrates a way to do this:
- * <informalexample><programlisting>
+ * |[
* gtk_init (&argc, &argv);
*
* /* make sure the type is realized */
* g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
*
* g_object_set (gtk_settings_get_default (), "gtk-enable-animations", FALSE, NULL);
- * </programlisting></informalexample>
+ * ]|
*
* There is one GtkSettings instance per screen. It can be obtained with
* gtk_settings_get_for_screen(), but in many cases, it is more convenient
* GtkSettings:gtk-color-scheme:
*
* A palette of named colors for use in themes. The format of the string is
- * <programlisting>
+ * |[
* name1: color1
* name2: color2
* ...
- * </programlisting>
+ * ]|
* Color names must be acceptable as identifiers in the
* <link linkend="gtk3-Resource-Files">gtkrc</link> syntax, and
* color specifications must be in the format accepted by
*
* Starting with GTK+ 2.12, the entries can alternatively be separated
* by ';' instead of newlines:
- * <programlisting>
+ * |[
* name1: color1; name2: color2; ...
- * </programlisting>
+ * ]|
*
* Since: 2.10
*
*
* <example>
* <title>A UI definition fragment with GtkSizeGroup</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkSizeGroup">
* <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
* <widgets>
* <widget name="radio2"/>
* </widgets>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
*
* <example>
* <title>Obtaining the window ID of a socket.</title>
- * <programlisting>
+ * |[
* GtkWidget *socket = gtk_socket_new (<!-- -->);
* gtk_widget_show (socket);
* gtk_container_add (GTK_CONTAINER (parent), socket);
* gtk_widget_realize (socket);
* g_print ("The ID of the sockets window is %#x\n",
* gtk_socket_get_id (socket));
- * </programlisting>
+ * ]|
* </example>
*
* Note that if you pass the window ID of the socket to another
*
* <example>
* <title>Using a GtkSpinButton to get an integer</title>
- * <programlisting>
+ * |[
* /* Provides a function to retrieve an integer value from a
* * GtkSpinButton and creates a spin button to model percentage
* * values.
*
* gtk_widget_show_all (window);
* }
- * </programlisting>
+ * ]|
* </example>
*
* <example>
* <title>Using a GtkSpinButton to get a floating point value</title>
- * <programlisting>
+ * |[
* /* Provides a function to retrieve a floating point value from a
* * GtkSpinButton, and creates a high precision spin button.
* */
*
* gtk_widget_show_all (window);
* }
- * </programlisting>
+ * ]|
* </example>
*/
* </para>
* <example>
* <title>Using an enumeration to identify animatable regions</title>
- * <programlisting>
+ * |[
* enum {
* REGION_ENTRY,
* REGION_BUTTON_UP,
*
* ...
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* For complex widgets with an arbitrary number of animatable regions, it
* </para>
* <example>
* <title>Using struct pointers to identify animatable regions</title>
- * <programlisting>
+ * |[
* void
* notebook_draw_tab (GtkWidget *widget,
* NotebookPage *page,
* gtk_render_extension (cr, page->x, page->y, page->width, page->height);
* gtk_style_context_pop_animatable_region (context);
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* The widget also needs to notify the style context about a state change
* </para>
* <example>
* <title>Triggering a state change animation on a region</title>
- * <programlisting>
+ * |[
* gboolean
* notebook_motion_notify (GtkWidget *widget,
* GdkEventMotion *event)
* TRUE);
* ...
* }
- * </programlisting>
+ * ]|
* </example>
* <para>
* gtk_style_context_notify_state_change() accepts %NULL region IDs as a
* In the CSS file format, a #GtkEntry defining an "entry"
* class, would be matched by:
*
- * <programlisting>
+ * |[
* GtkEntry.entry { ... }
- * </programlisting>
+ * ]|
*
* While any widget defining an "entry" class would be
* matched by:
- * <programlisting>
+ * |[
* .entry { ... }
- * </programlisting>
+ * ]|
*
* Since: 3.0
**/
* In the CSS file format, a #GtkTreeView defining a "row"
* region, would be matched by:
*
- * <programlisting>
+ * |[
* GtkTreeView row { ... }
- * </programlisting>
+ * ]|
*
* Pseudo-classes are used for matching @flags, so the two
* following rules:
- * <programlisting>
+ * |[
* GtkTreeView row:nth-child(even) { ... }
* GtkTreeView row:nth-child(odd) { ... }
- * </programlisting>
+ * ]|
*
* would apply to even and odd rows, respectively.
*
*
* As a practical example, a #GtkButton notifying a state transition on
* the prelight state:
- * <programlisting>
+ * |[
* gtk_style_context_notify_state_change (context,
* gtk_widget_get_window (widget),
* NULL,
* GTK_STATE_PRELIGHT,
* button->in_button);
- * </programlisting>
+ * ]|
*
* Can be handled in the CSS file like this:
- * <programlisting>
+ * |[
* GtkButton {
* background-color: #f00
* }
* background-color: #fff;
* transition: 200ms linear
* }
- * </programlisting>
+ * ]|
*
* This combination will animate the button background from red to white
* if a pointer enters the button, and back to red if the pointer leaves
*
* <example>
* <title>A UI definition fragment specifying tags</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkTextTagTable">
* <child type="tag">
* <object class="GtkTextTag"/>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* custom properties, for a theming engine named "Clearlooks" registering
* a "glossy" custom property, it could be referenced in the CSS file as
*
- * <programlisting>
+ * |[
* -Clearlooks-glossy: true;
- * </programlisting>
+ * ]|
*
* Since: 3.0
*/
*
* <example>
* <title>Creating two #GtkToggleButton widgets.</title>
- * <programlisting>
+ * |[
* void make_toggles (void) {
* GtkWidget *dialog, *toggle1, *toggle2;
*
*
* gtk_widget_show_all (dialog);
* }
- * </programlisting>
+ * ]|
* </example>
*/
*
* <example>
* <title>Acquiring a #GtkTreeIter-struct</title>
- * <programlisting>
+ * |[
* /* Three ways of getting the iter pointing to the location */
* GtkTreePath *path;
* GtkTreeIter iter;
* gtk_tree_model_iter_nth_child (model, &iter, &parent_iter, 2);
* parent_iter = iter;
* gtk_tree_model_iter_nth_child (model, &iter, &parent_iter, 5);
- * </programlisting>
+ * ]|
* </example>
*
* This second example shows a quick way of iterating through a list
*
* <example>
* <title>Reading data from a #GtkTreeModel</title>
- * <programlisting>
+ * |[
* enum
* {
* STRING_COLUMN,
*
* row_count++;
* }
- * </programlisting>
+ * ]|
* </example>
*
* The #GtkTreeModel interface contains two methods for reference
* empty. The visible function should therefore take special care of empty
* rows, like in the example below.
*
- * <informalexample><programlisting>
+ * |[
* static gboolean
* visible_func (GtkTreeModel *model,
* GtkTreeIter *iter,
*
* return visible;
* }
- * </programlisting></informalexample>
+ * ]|
*
* Since: 2.4
*/
*
* <example>
* <title>Using a #GtkTreeModelSort</title>
- * <programlisting>
+ * |[
* {
* GtkTreeView *tree_view1;
* GtkTreeView *tree_view2;
* gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model2),
* COLUMN_1, GTK_SORT_DESCENDING);
* }
- * </programlisting>
+ * ]|
* </example>
*
* To demonstrate how to access the underlying child model from the sort
*
* <example>
* <title>Accessing the child model of in a selection changed callback</title>
- * <programlisting>
+ * |[
* void
* selection_changed (GtkTreeSelection *selection, gpointer data)
* {
* -1);
* g_free (modified_data);
* }
- * </programlisting>
+ * ]|
* </example>
*/
* column. The "type" attribute specifies the data type for the column.
* <example>
* <title>A UI Definition fragment for a tree store</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkTreeStore">
* <columns>
* <column type="gchararray"/>
* <column type="gint"/>
* </columns>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
* internal #GtkTreeSelection in UI definitions.
* <example>
* <title>A UI definition fragment with GtkTreeView</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkTreeView" id="treeview">
* <property name="model">liststore1</property>
* <child>
* </object>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </refsect2>
*/
* Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
* generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height()
* it will do:
- * <programlisting><![CDATA[
+ * |[
* static void
* foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
* {
* it will return the minimum and natural height for the rotated label here.
* }
* }
- * ]]></programlisting>
+ * ]|
*
* And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return
* the minimum and natural width:
*
- * <programlisting><![CDATA[
+ * |[
* static void
* foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
* gint *min_width, gint *nat_width)
* height calculation here.
* }
* }
- * ]]></programlisting>
+ * ]|
*
* Often a widget needs to get its own request during size request or
* allocation. For example, when computing height it may need to also
* be careful to call its virtual methods directly, like this:
* <example>
* <title>Widget calling its own size request method.</title>
- * <programlisting>
+ * |[
* GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget),
* &min, &natural);
- * </programlisting>
+ * ]|
* </example>
*
* It will not work to use the wrapper functions, such as
* </para>
* <example>
* <title>A UI definition fragment specifying an accelerator</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkButton">
* <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* <para>
* In addition to accelerators, #GtkWidget also support a
* </para>
* <example>
* <title>A UI definition fragment specifying an accessible</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkButton" id="label1"/>
* <property name="label">I am a Label for a Button</property>
* </object>
* </object>
* </child>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* <para>
* Finally, GtkWidget allows style information such as style classes to
* be associated with widgets, using the custom <style> element:
* <example>
* <title>A UI definition fragment specifying an style class</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkButton" id="button1">
* <style>
* <class name="my-special-button-class"/>
* <class name="dark-button"/>
* </style>
* </object>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* <para>
* <example>
* <title>A GtkBuilder Template Definition</title>
- * <programlisting><![CDATA[
+ * |[
* <interface>
* <template class="FooWidget" parent="GtkBox">
* <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
* </child>
* </template>
* </interface>
- * ]]></programlisting>
+ * ]|
* </example>
* </para>
* </refsect2>
* The widget path generation is generally simple:
* <example>
* <title>Defining a button within a window</title>
- * <programlisting>
+ * |[
* {
* GtkWidgetPath *path;
*
* gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
* gtk_widget_path_append_type (path, GTK_TYPE_BUTTON);
* }
- * </programlisting>
+ * ]|
* </example>
*
* Although more complex information, such as widget names, or
*
* <example>
* <title>Defining the first tab widget in a notebook</title>
- * <programlisting>
+ * |[
* {
* GtkWidgetPath *path;
* guint pos;
* pos = gtk_widget_path_append_type (path, GTK_TYPE_LABEL);
* gtk_widget_path_iter_set_name (path, pos, "first tab label");
* }
- * </programlisting>
+ * ]|
* </example>
*
* All this information will be used to match the style information
* </para>
* <example>
* <title>A UI definition fragment with accel groups</title>
- * <programlisting><![CDATA[
+ * |[
* <object class="GtkWindow">
* <accel-groups>
* <group name="accelgroup1"/>
* ...
* <!-- -->
* <object class="GtkAccelGroup" id="accelgroup1"/>
- * ]]></programlisting>
+ * ]|
* </example>
* <para>
* The GtkWindow implementation of the GtkBuildable interface